<?php

namespace app\validator;

use think\Validate;

/**
 * Role save接口 验证器
 */
class RoleSave extends Validate{
    protected $rule = [
        'id'             => 'number|egt:0',
        'name'           => 'require',
        'status'         => 'in:0,1'
    ];

    protected $message = [
        'name.require'         => '角色名不能为空',
        'status.in'            => '状态值只能是0或1'
    ];

    protected $scene = [
        //  添加时不需要id
        'create'  => ['name', 'status'],
        //  更新时需要id
        'update' => ['id', 'name', 'status']
    ];
}